<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript" charset="utf-8">
		//Date()
		var time=new Date()
		var time1=new Date(2002,1,23,11,22,18)//注意，是2002年2月，0-11对应1-12
		
		//获取相关方法get
		var y=time.getFullYear()
		var m=time.getMonth()
		var d=time.getDate()
		var h=time.getHours()
		var Minutes=time.getMinutes()
		var Seconds=time.getSeconds()
		var day=time.getDay()//周几:1-7
		var t=time.getTime()//时间戳信息
		
		//设置相关方法set,和get类似
		time.setFullYear(2002)
		time.setMonth(2)
		time.setDate(23)
		//........
		//使用时间戳设置时间
		time.setTime(90000000000)
		
		
		//获取两个时间节点的时间差
		var time1=new Date()
		var time2=new Date(2022,1,1,0,0,0)

		//计算两个时间的差值
		function getDiff(time1,time2){
			var ms1=time1.getTime()
			var ms2=time2.getTime()
			var sub=ms2-ms1
			var sub=Math.ceil(sub/1000)
			var day =Math.floor( sub / ( 60 * 60 * 24 ) )
			var hours = Math.floor( sub % ( 60 * 60 * 24 ) / ( 60 * 60) )
			var minutes = Math.floor( sub % ( 60 * 60 ) / 60 )
			var seconds = sub % 60
			
			return{
				day:day,
				hours:hours,
				minutes:minutes,
				seconds:seconds
			}
		}
		console.log("距离明年还有:")
		console.log(getDiff(time1,time2))

		
		
		
		</script>
	</head>
	<body>

	</body>
</html>
